Skip to content

[Draft] Add stderr to process result output#751

Open
mdaudali wants to merge 1 commit intomasterfrom
mdaudali/stderrIsNice
Open

[Draft] Add stderr to process result output#751
mdaudali wants to merge 1 commit intomasterfrom
mdaudali/stderrIsNice

Conversation

@mdaudali
Copy link

@mdaudali mdaudali commented Feb 9, 2026

Before this PR

We don't have access to the stderr. When the process failed internally, the stdout made it seem like the error was related to something else (stdout!), which was misleading.

After this PR

Output returns stderr

==COMMIT_MSG==
==COMMIT_MSG==

Possible downsides?

It's a draft to discuss the format of the output:

  1. Changing it in this way now breaks anyone relying exactly on only getting the stdout, in both the output and the errorHandler
  2. I've marked empty as so it doesn't appear like there was an stderr that just got cutoff, but could equally just omit it entirely if no stderr. Chose this way because then it's explicit there's no stderr, rather than unsure if it just got missed e.t.c or a wrong plugin version.
  3. Little bit more verbose now than before.
  4. Includes it on a zero status code, though it's valid for programs to output to stderr on zero and it can be potentially useful (or alternatively framed, misleading to hide it)

I'll update the remainder of the tests once agreed on the format!

@changelog-app
Copy link

changelog-app bot commented Feb 9, 2026

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

[Draft] Add stderr to process result output

Check the box to generate changelog(s)

  • Generate changelog entry

.collect(Collectors.joining(System.lineSeparator()));

return String.format(
"STDERR: %s\n\n------\n\nSTDOUT: %s\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just use multi line strings here?

String commandOutput = dockerComposeCommand.execute(errorHandler, "rm", "-f");

assertThat(commandOutput).isEqualTo(expectedOutput);
assertThat(commandOutput).isEqualTo("STDERR: <empty>\n\n------\n\nSTDOUT: " + expectedOutput + "\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with multi line strings you should be able to do something like:

assertThat(commandOutput).isEqualTo(
  """
  STDERR: <empty>
  
  ------
  
  STDOUT:  %s
  """, expectedOutput);

assertj has some nice utility methods to do string formatting inside

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also gives me a way to see what the actual error message would look like.

So much so, I would actually just put the content for each stream on a new line

e.g.

STDERR:
<empty>

------
STDOUT:
%s

@felixdesouza
Copy link
Contributor

approach seems fine, you may end up breaking people if they expect only stdout, so maybe add an option to say "merge output streams" or something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants